<template>

<div class="input-group mb-3">
  <input v-model="bpm" type="text" class="form-control" placeholder="请输入挖矿频次" aria-label="Recipient's username" aria-describedby="button-addon2">
  <button @click="submit" class="btn btn-outline-secondary" type="button" id="button-addon2">提交</button>
</div>

  <table class="table table-primary">
  <thead>
    <tr>
      <th scope="col">参数</th>
      <th scope="col">值</th>
    </tr>
  </thead>
  <tbody v-if="dataLoading" >
    <tr v-for="(item,keys) in block0" :key="keys" >
      <td>{{ keys }}</td>
      <td>{{item}}</td>
    </tr>
  </tbody>
</table>
  <br>
  <div v-if="blockloading">
    <table class="table table-primary" v-for="(item,keys) in block" :key="keys">
    <thead>
    <tr>
      <th scope="col">参数</th>
      <th scope="col">值</th>
    </tr>
  </thead>
  <tbody>
    <tr v-for="(items,key) in item" :key="key" >
      <td>{{ key }}</td>
      <td>{{items}}</td>
    </tr>
  </tbody>
  </table>
  </div>


</template>

<script>
import local from "@/API/request";
// import { timers } from "jquery";
export default {
  name: 'TableSet',
  components: {
  },
  data(){
    return{
      blockloading: false,
      dataLoading: false,
      block0 : [],
      block : []
    }
  },
  mounted(){
    let that = this
    local.get("/getData").then(function(result){
      that.dataLoading = true,
      that.block0 = result.data[0]
      console.log(that.block0)
    })
  },
  methods:{
    submit(){
      let that = this
      const data = { "BPM" : Number(that.bpm) }
      local.post("/run",data).then(function(result){
        that.blockloading = true
        that.block = result.data
        console.log(that.block)
      })
    }
  }
}
</script>